<template>

<div class="wrap">

    <div class="page-order-checkout">
        <div class="page-order-checkout-wrap">
            <router-link :to="{name:'Address_list'}">
            <div class="b1 icon_arrow">
              <template v-if="address">
                <a href="address_list.html">
                    <div class="b11"><p><span>{{address.name}}</span><span>{{address.tel}}</span></p></div>
                    <div class="b13"><p>{{address.province}} {{address.city}} {{address.area}} {{address.detail}}</p></div>
                </a>
                </template>
              <template v-else>
                <div class="b11"><p><span>没有收货地址!</span></p></div>
                <div class="b13">
                  <p class="address" data-id="">
                    <span style="color:#FF5722;">亲, 请先填写一个收货地址~</span>
                  </p>
                </div>
              </template>
            </div>
            </router-link>

            <div class="ui_line"></div>
            <div class="b2">
                <ul>
                    <li class="on"><a href="javascript:;" class="alipaywap">微信支付</a></li>
                    <li class=""><a href="javascript:;" class="">货到付款</a></li>
                </ul>
            </div>
            <div class="ui_line"></div>

            <!--
            <div class="b3 icon_arrow">
                <dl>
                    <dt><span>电子发票</span><strong>发票类型</strong></dt>
                </dl>
            </div>
            <div class="b3 icon_arrow">
                <dl>
                    <dt><span>不限送货时间</span><strong>送货时间</strong></dt>
                </dl>
            </div>
            <div class="ui_line"></div>
            -->

            <div class="b8"  v-for="cart in carts">
                <div class="b8w">
                    <div class="b81">
                        <div class="img"><img :src="cart.product.thumb">
                        </div>
                    </div>
                    <div class="b82">
                        <div class="name"><p>
                            <span>{{cart.product.name}}</span></p></div>
                    </div>
                    <div class="b83">
                      <span>¥ {{cart.product.price}} x {{cart.num}} = </span>
                      <strong>{{cart.product.price*cart.num}}元</strong>
                    </div>
                </div>
              <!--v-repeat-cart.list-->
            </div>
            <div class="ui_line"></div>
            <div class="b5">
                <div class="b51"><p><strong>商品价格：</strong><span>{{count.total_price}}元</span></p></div>
                <div class="b53"><p><strong>配送费用：</strong><span>0元</span></p></div>
            </div>
            <div class="b7">
                <div class="b71"><span>共{{count.num}}件 合计: </span><strong>{{count.total_price}}元</strong></div>
                <div class="b72"><a href="javascript:;" class="ui-button"><router-link :to="{name:'Show_pay'}"><span>去付款</span></router-link></a></div>
            </div>
        </div>
    </div>

</div>
</template>
<script>

  export default {

    data() {
      return {
        carts:[],
        count:{},
        address:{}

      }
    },
    created() {
      this.init();
    },
    methods: {
      init() {
        let id = this.$route.params.id;
        this.axios.get(`/order/check_out?token=${localStorage.token}`)
          .then((response) => {
            console.log(response.data);
            this.carts = response.data.carts;
            this.count = response.data.count;
            this.address = response.data.address;
          })

        // .catch((error)=>{
        //   console.log(error.response.data.error)
        // if(error.response.data.error=='token_invalid'){
        //     alert('非法登录')
        //   this.$router.push({name:'Login'})
        // }
        // })
      },
    },
  }
</script>

